package com.ming.mina.server;

import com.ming.mina.handel.MessageHandel;
import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;

/**
 * @Auther: tangC
 * @Date: 2020/7/30 13:29
 * @Description:
 */
public class ServerOne {



    public static void main(String [] args) throws IOException {
        NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
        acceptor.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))));
        acceptor.setHandler(new MessageHandel());
        acceptor.bind(new InetSocketAddress(9999));
    }
}
